home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <dos/dos.h>
- #include <dos/dosextens.h>
- #include <dos/dostags.h>
- #include <dos/notify.h>
- #include <string.h>
- #include <libraries/WBStart.h>
- #include <workbench/startup.h>
- #include <workbench/workbench.h>
- #include <intuition/classes.h>
- #include <clib/macros.h>
- #include "gaugeclass.h"
- #include "tinymeter.h"
- #include "launchclass.h"
-
- getVolsize(struct tm_data *data,char *volname)
- {
- struct InfoData inf;
- struct DevProc *devproc;
- if(devproc=(struct DevProc *)GetDeviceProc(volname,NULL))
- {
- if( DoPkt(devproc->dvp_Port,ACTION_DISK_INFO,MKBADDR(&inf),NULL,NULL,NULL,NULL)==DOSTRUE)
- {
- switch(inf.id_DiskType)
- {
- case 0x42555359:
- data->volmax=0;
- data->volcur=GAU_err_busy;
- break;
- case ID_UNREADABLE_DISK:
- data->volmax=0;
- data->volcur=GAU_err_unreadable;
- break;
- case ID_NOT_REALLY_DOS:
- data->volmax=0;
- data->volcur=GAU_err_nodos;
- break;
- case ID_NO_DISK_PRESENT:
- data->volmax=0;
- data->volcur=GAU_err_notpresent;
- break;
- case ID_KICKSTART_DISK:
- data->volmax=0L;
- data->volcur=GAU_err_kickstart;
- break;
- default:
- data->volcur=(inf.id_NumBlocks-inf.id_NumBlocksUsed)*inf.id_BytesPerBlock;
- data->volmax=inf.id_NumBlocks*inf.id_BytesPerBlock;
- data->voltype=inf.id_DiskType;
- break;
- }
- }
- FreeDeviceProc(devproc);
- }
- else
- {
- data->volmax=0;
- data->volcur=GAU_err_notmount;
- }
- }
-
- BOOL CopyPathList(struct PathList **pla, struct PathList **plc,struct PathList *oldpl)
- {
- struct PathList *pl1=oldpl,*pl2=*plc,*pl3=NULL;
- while (pl1)
- {
- if (!(pl3 || (pl3=(struct PathList *)AllocVec(sizeof(struct PathList),MEMF_PUBLIC|MEMF_CLEAR)))) return(FALSE);
- if (pl3->PathLock=DupLock(pl1->PathLock))
- {
- if (*pla) pl2->NextPath=MKBADDR(pl3);
- else *pla=pl3;
- pl2=pl3;
- pl3=NULL;
- }
- pl1=BADDR(pl1->NextPath);
- }
- if (pl3) FreeVec(pl3);
- *plc=pl2;
- return(TRUE);
- }
-
- void FreePathList(struct PathList *pla)
- {
- if (pla)
- {
- struct PathList *pl1=pla,*pl2;
- do
- {
- pl2=BADDR(pl1->NextPath);
- UnLock(pl1->PathLock);
- FreeVec(pl1);
- }
- while (pl1=pl2);
- }
- }
-
- BOOL InitWorkbenchPath(struct tm_data *data)
- {
- struct Process *wbproc=(struct Process *)FindTask("Workbench");
- if(!wbproc) wbproc=(struct Process *)FindTask("DirectoryOpus");
-
- if (wbproc && (wbproc->pr_Task.tc_Node.ln_Type==NT_PROCESS))
- {
- struct CommandLineInterface *wbcli=BADDR(wbproc->pr_CLI);
- if (wbcli)
- {
- struct PathList *dummy;
- if (CopyPathList(&data->GlobalPath,&dummy,(struct PathList *) BADDR(wbcli->cli_CommandDir)));
- }
- }
- return(TRUE);
- }
-
- FreeWorkbenchPath(struct tm_data *data)
- {
- FreePathList(data->GlobalPath);
- }
-
- RunCLI(struct lau_entry *entry, struct tm_data *data)
- {
- BOOL rc=TRUE;
- char *def =0;
- BPTR newcd,
- ofh,
- oldcd,
- ifh;
- struct MsgPort *newct=NULL;
-
- if(entry->lau_pth) newcd=Lock(entry->lau_pth,SHARED_LOCK);
- else newcd=0L;
- if(!newcd)
- {
- char *foo;
- int i;
- foo=(char *)FilePart(entry->lau_cmd);
- if(def=(char *)AllocVec(foo-entry->lau_cmd+2,0L))
- {
- for(i=0;i<(foo-entry->lau_cmd);i++) def[i]=entry->lau_cmd[i];
- def[i]=0;
- newcd=Lock(def,SHARED_LOCK);
- }
- }
- if(!(ofh=Open(entry->lau_out, MODE_NEWFILE)))
- ofh=Open("NIL:", MODE_NEWFILE);
- if(ofh)
- {
- if (IsInteractive(ofh))
- {
- struct MsgPort *oldct;
- newct=((struct FileHandle *) BADDR(ofh))->fh_Type;
- oldct=(struct MsgPort *)SetConsoleTask(newct);
- ifh=Open("CONSOLE:",MODE_OLDFILE);
- SetConsoleTask(oldct);
- }
- else ifh=Open("NIL:",MODE_OLDFILE);
- if (ifh)
- {
- struct PathList *pla=NULL,*plc=NULL;
- oldcd=CurrentDir(newcd);
- if(CopyPathList(&pla,&plc,data->GlobalPath))
- {
- if (SystemTags(entry->lau_cmd,
- SYS_Output, ofh,
- SYS_Input, ifh,
- SYS_Asynch, TRUE,
- SYS_UserShell, TRUE,
- NP_StackSize, entry->lau_stack < 4096L ? 4096L : entry->lau_stack,
- NP_Priority, 0,
- NP_Path, MKBADDR(pla),
- NP_ConsoleTask, newct,
- TAG_DONE)!=-1) rc=FALSE;
- CurrentDir(oldcd);
- if(rc)
- {
- Close(ifh);
- FreePathList(pla);
- }
- }
- }
- if(rc)
- {
- Close(ofh);
- DisplayBeep(0);
- }
- }
- if(def)FreeVec(def);
- UnLock(newcd);
- }
-
- RunWB(struct lau_entry *entry, struct tm_data *data)
- {
- if(WBStartTags(WBStart_Name, entry->lau_cmd,
- WBStart_DirectoryName, entry->lau_pth,
- WBStart_Stack, entry->lau_stack < 4096L ? 4096L : entry->lau_stack,
- TAG_END))
- {
- DisplayBeep(0);
- }
- }
-
- int RunFile(struct lau_entry *entry, struct tm_data *data)
- {
- if(entry->lau_type==0) RunWB(entry,data);
- else RunCLI(entry,data);
- }
-
-
-